package cn.iocoder.yudao.module.crm.api.clue.dto;

import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.ToString;

import java.time.LocalDateTime;

@Data
@ToString(callSuper = true)
public class CrmClueDTO {

    private Long id;

    private String name;

    private String followUpStage;

    private Boolean followUpStatus;

    private LocalDateTime contactLastTime;

    private String contactLastContent;

    private LocalDateTime contactNextTime;

    private Long ownerUserId;

    private String ownerUserName;

    private String ownerUserDeptName;

    private Boolean transformStatus;

    private Long customerId;

    private String customerName;

    private String mobile;

    private String telephone;

    private String qq;

    private String wechat;

    private String email;

    private Integer areaId;

    private String areaName;

    private String detailAddress;

    private Integer industryId;

    private Integer level;

    private Integer source;

    private String remark;

    private String creator;

    private String creatorName;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    private LocalDateTime ownerTime;

    private int profileScore;

    private Long poolId;

    private Long poolDay;

    private LocalDateTime intoPoolTime;

    // 是否来自广告转入
    private Integer adTrans;

    // 广告记录id
    private Long adLogId;

    private Long moduleId;

    private Long stageId;

    private Integer dataType;

    private String moduleName;

    public void calculateProfile() {
        int score = 0;
        if (StrUtil.isNotEmpty(this.name)) {
            score++;
        }
        if (ObjUtil.isNotNull(this.source)) {
            score++;
        }
        if (ObjUtil.isNotEmpty(this.telephone)) {
            score++;
        }
        if (ObjUtil.isNotEmpty(this.mobile)) {
            score++;
        }
        if (ObjUtil.isNotEmpty(this.areaName)) {
            score++;
        }
        if (ObjUtil.isNotEmpty(this.qq)) {
            score++;
        }
        if (ObjUtil.isNotEmpty(this.wechat)) {
            score++;
        }
        if (ObjUtil.isNotNull(this.industryId)) {
            score++;
        }
        if (ObjUtil.isNotNull(this.level)) {
            score++;
        }
        if (ObjUtil.isNotEmpty(this.remark)) {
            score++;
        }
        this.profileScore = Math.floorDiv(score * 100, 10);
    }

}
